<template>
	<view class="wanl-money">
		<wanl-navbar :isBack="true" :background="{background: '#fff',}" :showGongNeng="true"
			style="border-bottom: 2rpx solid #f8f8f8">
			<text slot="content" style="color: #000; width: 100%;padding-left: 20rpx;">
				算力明细
			</text>
		</wanl-navbar>
		<view class="edgeInsetTop"></view>
		<view class="cu-list menu-avatar" v-if="dataList">
			<!--			@tap="toMoney(item)"-->
			<view class="cu-item" v-for="(item, index) in dataList" :key="item.id">
				<view class="cu-avatar round bg-red">
					<text class="wlIcon-fuwuqi1"></text>
				</view>
				<view class="content">
					<view class="text-sm flex">
						<view class="text-cut">
							{{item.memo}}
						</view>
					</view>
					<view class="wanl-gray text-sm text-bold">{{payType[item.type]}}</view>
					<view class="wanl-gray text-sm">
						{{ $wanlshop.timeToDate(item.createtime) }}
					</view>
				</view>
				<view class="action">
					<view class="text-lg" :class="item.money > 0 ? 'wanl-orange' : 'wanl-black'">
						{{ item.money > 0 ? '+'+item.money:item.money}}</view>
				</view>
			</view>
		</view>
		<!-- 空 -->
		<view v-if="dataList.length == 0">
			<wanl-empty src="ticket_default3x" text="没找到任何算力使用明细" />
		</view>
		<view class="edgeInsetBottom"></view>
		<uni-load-more :status="status" :content-text="contentText" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				payType: {
					pay: '商品交易',
					groups: '拼团',
					recharge: '充值',
					withdraw: '提现',
					refund: '退款',
					sys: '系统',
				},
				reload: false, //判断是否上拉
				total: 0, //数据量
				current_page: 1, //当前页码
				last_page: 1, //总页码
				status: 'more',
				contentText: {
					contentdown: ' ',
					contentrefresh: '加载中',
					contentnomore: ''
				}
			};
		},
		onLoad() {
			this.loadData();
		},
		onPullDownRefresh() {
			this.current_page = 1;
			this.reload = true;
			this.loadData();
		},
		onReachBottom() {
			//判断是否最后一页
			if (this.current_page >= this.last_page) {
				this.status = 'noMore';
			} else {
				this.reload = false;
				this.current_page = this.current_page + 1; //页码+1
				this.status = 'loading';
				this.loadData();
			}
		},
		methods: {
			async loadData() {
				await uni.request({
					url: '/wanlshop/user/yuanbao_lists',
					method: 'POST',
					data: {
						page: this.current_page
					},
					success: res => {
						uni.stopPullDownRefresh();
						this.dataList = this.reload ? res.data.data : this.dataList.concat(res.data
						.data); //数据 追加
						this.total = res.data.total; //数据量
						this.current_page = res.data.current_page; //当前页码
						this.last_page = res.data.last_page; //总页码
						this.status = res.data.total == 0 ? 'noMore' : 'more';
					}
				});
			},
			// toMoney(item){
			// 	this.$wanlshop.to(`/pages/user/money/details?data=${JSON.stringify(item)}`);
			// }
		}
	};
</script>

<style>
	.wanl-money .balance {
		margin: 10rpx 25rpx 25rpx 25rpx;
	}

	.wanl-money .balance .details {
		padding: 50rpx 0;
	}

	.wanl-money .balance .operate {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: rgba(0, 0, 0, 0.1);
		height: 80rpx;
		color: #fff;
	}

	.wanl-money .cu-list.menu-avatar>.cu-item {
		height: 180rpx;
		align-items: flex-start;
		padding: 25rpx 0;
	}

	.wanl-money .cu-list.menu-avatar>.cu-item .cu-avatar {
		width: 75rpx;
		height: 75rpx;
		left: 25rpx;
		margin-top: 6rpx;
	}

	.wanl-money .cu-list.menu-avatar>.cu-item .content {
		left: 120rpx;
		width: calc(100% - 75rpx - 25rpx -150rpx);
		line-height: 1.5em;
	}

	.wanl-money .cu-list.menu-avatar>.cu-item .action {
		width: 220rpx;
		text-align: right;
		padding-right: 25rpx;
	}
</style>